Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements in the rendering of math and references. rST ZIPs now support $...$ for inline math. #953

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

daira
Copy link
Collaborator

@daira daira commented Nov 8, 2024

  • Make the style of reference links and references (almost) consistent between Markdown and reStructuredText.

  • The $...$ syntax can now be —and is— used in rST, except in tables and headings. fixes Make $...$ work in reStructuredText ZIPs #952

    The reason why $...$ doesn't work in general for tables and headings is that replacing it with :math:`...` throws off the column-sensitive markup. Things like that are why column-sensitive markup is a bad idea.

  • In most cases when using $...$ followed by a punctuation mark, there is no need to manually correct spacing (in either rST or Markdown). The render.sh script does it automatically if required. This does not apply to :math:`...`.

  • Math is rendered using KaTeX instead of MathJax. fixes Switch from MathJax to KaTeX for ZIP rendering #432, fixes The size of rendered math in ZIPs is inconsistent between reloads #375

  • The rendering of math from Markdown is greatly improved. Previously it could only handle simple expressions that could be rendered at low quality as text; now it supports everything that KaTeX supports, and the quality of rendering is consistent (if not quite up to pdflatex standards).

  • This PR is also preparation for switching to MultiMarkdown. MultiMarkdown fixes the duplicate reference bug (References are duplicated in the rendering of Markdown ZIPs #893) and also has some nice features like colspan in tables (use $n$ | characters on the right-hand-side of a table entry to make it span $n$ columns).

@daira
Copy link
Collaborator Author

daira commented Nov 8, 2024

This should be merged after #951 [edit: which is now merged].

@daira daira marked this pull request as draft November 8, 2024 14:32
@daira daira marked this pull request as ready for review November 8, 2024 20:12
@daira daira requested a review from str4d November 8, 2024 20:15
@daira daira requested a review from nuttycom November 8, 2024 23:10
@daira
Copy link
Collaborator Author

daira commented Nov 8, 2024

When reviewing this, please also check how reference links and the References section look after the CSS changes. That might vary between browsers; I only tested desktop Firefox (115.1.0esr) and Chromium (124.0.6367.118) on Debian. It's difficult to test mobile without having GitHub Pages rendering of PRs.

@daira daira changed the title Easier math in reStructuredText Easier math in reStructuredText; make references consistent between Markdown and rST Nov 9, 2024
@daira daira changed the title Easier math in reStructuredText; make references consistent between Markdown and rST Make references consistent between Markdown and rST, and allow $...$ for inline math in rST Nov 9, 2024
@daira daira added S-scratching-an-itch Status: Something we haven't planned for a sprint but are doing anyway ZIP rendering labels Nov 9, 2024
@daira daira changed the title Make references consistent between Markdown and rST, and allow $...$ for inline math in rST Various improvements in the rendering of math and references. rSt now supports $...$ for inline math. Nov 9, 2024
@daira daira force-pushed the easier-math-in-rst branch 2 times, most recently from f472b90 to a9fc3ae Compare November 9, 2024 22:36
@daira daira force-pushed the easier-math-in-rst branch 3 times, most recently from 7e35f12 to 7c2bd6c Compare November 10, 2024 04:56
@daira daira changed the title Various improvements in the rendering of math and references. rSt now supports $...$ for inline math. Various improvements in the rendering of math and references. rST ZIPs now support $...$ for inline math. Nov 10, 2024
else
if [ "x$1" = "x--pandoc" ]; then
# Not actually MathJax. KaTeX is compatible if we use the right headers.
pandoc --mathjax --from=markdown --to=html "${inputfile}" --output="${outputfile}.temp"
Copy link
Collaborator Author

@daira daira Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I had to add --mathjax (relative to the pandoc command that was previously in the Makefile) as part of switching from MathJax to KaTeX. That's because KaTeX is compatible with MathJax's representation of math spans as:

<span class="math">\(latex code\)</span>

(class="math inline" also works.) Previously the \( \) delimiters were not being added by pandoc; that's what the --mathjax option does. multimarkdown adds them without an explicit option.

@daira
Copy link
Collaborator Author

daira commented Nov 10, 2024

The reason why I didn't just immediately switch to MultiMarkdown in this PR, is that it is not packaged for Linux distributions. It has to be built from source (requiring CMake, for the current version). The build is pretty straightforward though, so I'll switch the default once I've added it to the docker image and added some documentation.

…tent

between Markdown and reStructuredText.

(This also anticipates a possible switch from Pandoc to Multimarkdown;
the changes are designed to work with both.)

Signed-off-by: Daira-Emma Hopwood <[email protected]>
Signed-off-by: Daira-Emma Hopwood <[email protected]>
(zip-guide *incorrectly* said that we were already using KaTeX. This has
been wrong since zcash#645.)

Signed-off-by: Daira-Emma Hopwood <[email protected]>
Signed-off-by: Daira-Emma Hopwood <[email protected]>
This supports MultiMarkdown as well as Pandoc, using
`make MARKDOWN_OPTION=--mmd`

Signed-off-by: Daira-Emma Hopwood <[email protected]>
Signed-off-by: Daira-Emma Hopwood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-scratching-an-itch Status: Something we haven't planned for a sprint but are doing anyway ZIP rendering
Projects
None yet
1 participant